﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ReportViewer.aspx.cs" Inherits="LineOfBusiness.ReportViewer" %>
<%@ Register assembly="LineOfBusiness.Controls" namespace="LineOfBusiness.Controls" tagprefix="cc1" %>

<!DOCTYPE html>

<html>
<head id="Head1" runat="server">
    <title><%=Request.QueryString["FormTitle"] %></title>
    
    <link href="Content/kendo/kendo.common.min.css" rel="stylesheet" type="text/css" />
    <link href="Content/kendo/kendo.blueopal.min.css" rel="stylesheet" type="text/css" />

    <script src="Scripts/jquery.min.js" type="text/javascript"></script>
    <script src="Scripts/kendo/kendo.web.min.js" type="text/javascript"></script>
    <script src="Scripts/site.js" type="text/javascript"></script>
    <script src="Scripts/WindowPopup.js" type="text/javascript"></script>

    

      <style type="text/css">
        .ToolBarImageVisible
        {
            width:16px;
            height:16px;
            display:inline;
            vertical-align: middle;
        }
        .ToolBarImageHidden
        {
            width:16px;
            height:16px;
            display:none;
            vertical-align: middle;
        }

        #TextBoxPageNumber {
              width:30px;
          }
          #DropDownListExport {
              width:100px;
          }
        .ToolBarText
        {
            font-size:small; 
            height:16px ; 
            vertical-align:middle ;
        }
        .ToolBarList
        {
            vertical-align:middle;
            height:22px ; 
        }
        .ToolBarLink
        {
            border-style:none;
            font-size:small; 
            color:blue;
            vertical-align:middle;
        }

        
        .toolbarpanel {
            -moz-border-radius-bottomleft: 5px;
            -moz-border-radius-bottomright:5px;
            -webkit-border-bottom-left-radius:5px;
            -webkit-border-bottom-right-radius:5px;
            border-bottom-left-radius:5px;
            border-bottom-right-radius:5px;
            width: 100%;
	        display:inline-block; 
	        background-color:rgb(218, 236, 244);
            height:28px; 
            position:fixed;
            overflow:hidden;
            top:0px;
            left:0px;
        }

         .toolbarpanel1 {
            margin-top:4px;
            margin-left:10px;
        }

         
    .reportpannel
    {
      
    }


         body
    {
        background: #ffffff;
        font-family:Arial;
        color: #666666;
        margin: 0;
        padding: 0;
        
    }
    </style>
</head>
<body>
    
<script type="text/javascript">
    var heightReport = 0;
    var widthReport = 0;
</script>
    
    <div>
        <form id="Form1" runat="server">
          <asp:ScriptManager ID="ScriptManager1" runat="server">
            <Scripts>
                <asp:ScriptReference Path="~/Scripts/CustomToolBar.js" />
            </Scripts>
        </asp:ScriptManager>

             <div id="panReport" class="reportpannel" style="margin-top:0px;background-color:white;padding-left:20px;padding-top:40px">
        <cc1:LOBReportViewer ID="ReportViewer1" runat="server" AsyncRendering="False" ShowToolBar="False" SizeToReportContent="true"
            Width="100%" Height="97%"></cc1:LOBReportViewer>        
                </div>
        <!-- Use an UpdatePanel to contain the custom toolbar items. While the page only contains the custom toolbar and the ReportViewer control, a trigger 
             is defined here so that in case there are other UpdatePanel controls, the custom toolbar is only updated by changes in the ReportViewer control. 
             Also, both the enabled and disabled buttons are defined. At run time the client-side code will toggle the visibility of the buttons accordingly.
             NOTE: If there are other controls on your page that cause changes in the ReportViewer on asynchronous postbacks, you should add them here as 
             triggers, or call UpdatePanel.Update() in the code behind to force the toolbar to be updated. -->
        <div class="toolbarpanel">
        <asp:UpdatePanel ID="ToolBarPanel" runat="server" UpdateMode="Conditional">
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="ReportViewer1" />
            </Triggers>
            <ContentTemplate>
        <!-- This hidden field is used to pass a JSON object to the client-side for updating the toolbar state. -->
        <asp:HiddenField 
            id="ToolBarSerializedState" 
            runat="server" />
        <asp:HiddenField 
            id="NoData" 
            runat="server" />
                <asp:ImageButton 
                    ID="ButtonFirstPage" 
                    runat="server" 
                    onclick="ButtonFirstPage_Click" 
                    CssClass="ToolBarImageHidden" 
                    ImageUrl="~/Content/reporticon/FirstPage.gif" />
                <asp:ImageButton 
                    ID="ButtonFirstPageDisabled" 
                    runat="server" 
                    Enabled="False" 
                    CssClass="ToolBarImageVisible"
                    ImageUrl="~/Content/reporticon/FirstPageDisabled.gif" />
                <asp:ImageButton 
                    ID="ButtonPreviousPage" 
                    runat="server" 
                    onclick="ButtonPreviousPage_Click" 
                    CssClass="ToolBarImageHidden"
                    ImageUrl="~/Content/reporticon/PrevPage.gif" />
                <asp:ImageButton 
                    ID="ButtonPreviousPageDisabled" 
                    runat="server" 
                    Enabled="False" 
                    CssClass="ToolBarImageVisible"
                    ImageUrl="~/Content/reporticon/PrevPageDisabled.gif" />
                <asp:TextBox 
                    ID="TextBoxPageNumber" 
                    runat="server"
                    OnTextChanged="TextBoxPageNumber_TextChanged"
                    Text="" 
                    Enabled="False"
                    CssClass="ToolBarText"
                    Columns="5" />
                <asp:Label 
                    ID="LabelTotalPages" 
                    runat="server" 
                    CssClass="ToolBarText"
                    Text="of 0" 
                    Width="40px" />
                <asp:ImageButton 
                    ID="ButtonNextPage" 
                    runat="server" 
                    onclick="ButtonNextPage_Click" 
                    CssClass="ToolBarImageHidden"
                    ImageUrl="~/Content/reporticon/NextPage.gif" />
                <asp:ImageButton 
                    ID="ButtonNextPageDisabled" 
                    runat="server" 
                    Enabled="False"
                    CssClass="ToolBarImageVisible"
                    ImageUrl="~/Content/reporticon/NextPageDisabled.gif" />
                <asp:ImageButton 
                    ID="ButtonLastPage" 
                    runat="server" 
                    onclick="ButtonLastPage_Click" 
                    CssClass="ToolBarImageHidden"
                    ImageUrl="~/Content/reporticon/LastPage.gif" />
                <asp:ImageButton 
                    ID="ButtonLastPageDisabled" 
                    runat="server" 
                    Enabled="False" 
                    CssClass="ToolBarImageVisible"
                    ImageUrl="~/Content/reporticon/LastPageDisabled.gif" />
                &nbsp;&nbsp;
                <asp:ImageButton ID="ButtonBackToParent" 
                    runat="server" 
                    onclick="ButtonBackToParent_Click" 
                    CssClass="ToolBarImageHidden" 
                    ImageUrl="~/Content/reporticon/BackEnabled.gif" />
                <asp:ImageButton ID="ButtonBackToParentDisabled" 
                    runat="server" 
                    Enabled="False" 
                    CssClass="ToolBarImageVisible"
                    ImageUrl="~/Content/reporticon/BackDisabled.gif" />
                <asp:DropDownList 
                    ID="DropDownListZoom" 
                    runat="server" 
                    CausesValidation="True" 
                    EnableViewState="True" 
                    Enabled="False"
                    CssClass="ToolBarList" >
                    <asp:ListItem Value="PageWidth">Page Width</asp:ListItem>
                    <asp:ListItem Value="FullPage">Full Page</asp:ListItem>
                    <asp:ListItem Value="500">500%</asp:ListItem>
                    <asp:ListItem Value="200">200%</asp:ListItem>
                    <asp:ListItem Value="150">150%</asp:ListItem>
                    <asp:ListItem Selected="True" Value="100">100%</asp:ListItem>
                    <asp:ListItem Value="75">75%</asp:ListItem>
                    <asp:ListItem Value="50">50%</asp:ListItem>
                    <asp:ListItem Value="25">25%</asp:ListItem>
                    <asp:ListItem Value="10">10%</asp:ListItem>
                </asp:DropDownList>
                <asp:TextBox 
                    ID="TextBoxFindString" 
                    runat="server" 
                    Enabled="False"
                    CssClass="ToolBarText"
                    Columns="10" />
                <asp:Button 
                    ID="ButtonFind" 
                    runat="server" 
                    Text="Find" 
                    Enabled="False" 
                    CssClass="ToolBarLink" />
                <asp:Literal 
                    ID="LiteralBar" 
                    runat="server" 
                    Text="|" />
                <asp:Button 
                    ID="ButtonNext" 
                    runat="server" 
                    Text="Next" 
                    Enabled="False" 
                    CssClass="ToolBarLink" />
                <asp:DropDownList 
                    ID="DropDownListExport" 
                    runat="server" 
                    Enabled="False"
                    CssClass="ToolBarList" />
                <asp:ImageButton 
                    ID="ButtonRefresh" 
                    runat="server" 
                    CssClass="ToolBarImageHidden" 
                    ImageUrl="~/Content/reporticon/Refresh.gif" />
                <asp:ImageButton 
                    ID="ButtonRefreshDisabled" 
                    runat="server" 
                    Enabled="False" 
                    CssClass="ToolBarImageVisible"
                    ImageUrl="~/Content/reporticon/RefreshDisabled.gif" />
                <asp:ImageButton 
                    ID="ButtonPrint" 
                    runat="server" 
                    CssClass="ToolBarImageHidden"
                    ImageUrl="~/Content/reporticon/Print.gif" />
                <asp:ImageButton 
                    ID="ButtonPrintDisabled" 
                    runat="server" 
                    Enabled="False" 
                    CssClass="ToolBarImageVisible" 
                    ImageUrl="~/Content/reporticon/PrintDisabled.gif" />
                <img ID="ImageLanguage" onclick="ShowLanguage()" 
                    class="ToolBarImageVisible"
                    src="Content/images/toolbar/flag.png" />

                <a href="Content/file/ReportBuilder3.msi" >
                    <img ID="Img2"  style="width:20px;height:20px"
                    class="ToolBarImageVisible"
                    title="Download report builder"
                    src="Content/reporticon/download.png" />
                </a>
                
                <a id="designrdlc">
                <img ID="Img1"   style="width:20px;height:20px"
                    class="ToolBarImageVisible"
                    title="Design Report"
                    src="Content/reporticon/design.png" />
                </a>

                <img ID="Img3" onclick="UploadReport()"
                    class="ToolBarImageVisible"
                    title="Upload Report"
                    src="Content/reporticon/upload.png" />

                <img ID="Img4" onclick="ResetReport()"
                    title="Reset default"
                    class="ToolBarImageVisible"
                    src="Content/reporticon/reset.png" />

                <a id="pivottable">
                <img ID="Img5"
                    title="Pivot table excel"
                    class="ToolBarImageVisible"
                    src="Content/reporticon/cube.png" />
                </a>
            </ContentTemplate>
        </asp:UpdatePanel>
        </div>
        
           
        </form>
    </div>
    

<script type="text/javascript">

    var managewindow = new Array(0);
    
    $(window).resize(function () {
        Resize();
    });

    $(window).load(function () {
        Resize();
    });

    $(document).ready(function () {
        $("#ToolBarPanel").addClass("toolbarpanel1");
        //Resize();

        if ($get("NoData").value == "1") {
            alert("Report No Data")
            close();
            document.location = "http://www.lacviet.com.vn/lcmsweb/default.aspx";
        }

       

    });



    $.extend({
        getUrlVars: function () {
            var vars = [], hash;
            var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
            for (var i = 0; i < hashes.length; i++) {
                hash = hashes[i].split('=');
                vars.push(hash[0]);
                vars[hash[0]] = hash[1];
            }
            return vars;
        },

        getUrlVar: function (name) {
            return $.getUrlVars()[name];
        }
    });


    function Resize()
    {
        
        
        //var heightReport = document.getElementById("ReportViewer1_ReportViewer").offsetHeight + 40;
        //var widthReport = document.getElementById("ReportViewer1_ReportViewer").offsetWidth + 40;
        //var landscape = $.getUrlVar("l");
        //var autoh = $.getUrlVar("autoh");
        //if (landscape == "1")
        //{
        //    if (heightReport < 850) heightReport = 850;
        //    //heightReport = 850;
        //    widthReport = 1070;
        //}
        //else
        //{

        //    if (heightReport < 1185) heightReport = 1185;
        //    //heightReport = 1185;
        //    widthReport = 770;
        //}

        
        //$("#panReport").width(widthReport);
        //if(autoh!=1)
        //    $("#panReport").height(heightReport);

        //var left = ($(window).width() - widthReport) / 2;
        //if (left < 0) left = 0;

        //var pan = 30;
       
        //if (landscape != "1") pan = pan + 20;
        //$("#panReport").css("margin-left", left);
        //$("#panReport").css("padding-left", pan);

        //var url = document.location.href.replace('ReportViewer.aspx', 'PrintReport.axd');
        

        //$("#pivottable").attr("href", url + "&PivotTableExcel=1");
        //$("#designrdlc").attr("href", url + "&Download=1");
    }

    function printDialogNotIE()
    {
        var url = document.location.href;
        document.location.href = url + "&Print=1";
    }

    function ShowLanguage()
    {
        url = "Shared/ViewLanguage?FormNameShow=<%= Request.QueryString["Module"] + Request.QueryString["ReportName"] %>&formName=FormLabels&gridViewName=grvFormLabels&entityName=SYS_FormLabels";
        ShowWindowCallback(url, 600, 550, "Show Language", function (r) { if (r == 1) document.location.reload(); }, 1, "");
    }
    function UploadReport() {
        ShowWindowCallback('Home/UpLoadCustomReport?Module=<%=Request.QueryString["Module"]%>&ReportName=<%=Request.QueryString["ReportName"]%>&Dynamic=<%=Request.QueryString["Dynamic"]%>', 450, 50, 'Select Report', function (result) {
            if (result == "1") {
                document.location.reload();
            }
        });
    }
    function ResetReport()
    {
        PostServer('Home/ResetReport?Module=<%=Request.QueryString["Module"]%>&ReportName=<%=Request.QueryString["ReportName"]%>&Dynamic=<%=Request.QueryString["Dynamic"]%>');
        document.location.reload();
    }
    
    function PivotTable()
    {

    }
</script>

</body>
</html>